from optparse import OptionParser

from slum.model.song import Song
from slum.model.artist import Artist

from sqlalchemy import create_engine
from sqlalchemy import MetaData

def init_parser():
    parser = OptionParser()
    parser.set_defaults(
        create=False,
        data='trips.csv',
        db='sqlite:///slum.db',
        format='extended',
        schema=None,
    )
    parser.add_option(
        "-c", "--create", action="store_true", dest="create",
        help="Create database tables"
    )
    parser.add_option(
        "-d", "--database", dest="db",
        help="Database connection string for engine"
    )
    parser.add_option(
        "-f", "--csv", dest="data",
        help="CSV file name for trip parameters"
    )
    parser.add_option(
        "-s", "--schema", dest="schema",
        help="Optional database schema name"
    )
    (options, args) = parser.parse_args()
    return options


def main():
    options = init_parser()
    db = create_engine(options.db)
    db.echo = False
    metadata = MetaData(db)
    if options.create:
        Song.metadata.drop_all(bind=db)
        Song.metadata.create_all(bind=db)


    c = Song();

if __name__ == '__main__':
    main()
